<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

    /*
        JSON.stringify()
            .parse()
     */
    let book = {
        title: 'Everything\'s all right',
        authors: [
            'to the moon',
            'back here'
        ],
        edition: 4,
        year: 2019
    }
    // 将js对象转为json字符串
    let jsonText = JSON.stringify(book)
    /*
        {"title":"Everything's all right","authors":["to the moon","back here"],"edition":4,"year":2019}
     */
    console.log(jsonText)
    
    // 将json对象转为js对象
    console.log(JSON.parse(jsonText)) // 结果为打印book
    

</script>
</body>
</html>